chore: remove cycle dependency of EventService and StateService#406
chore: remove cycle dependency of EventService and StateService#406sampaiodiego wants to merge 4 commits into
Conversation
EventService.notify() now delegates to the new concrete service. No behavior change; first step toward removing the EventService/StateService circular dependency. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
StateService no longer depends on EventService — its only reverse call was notify() in processInitialState(), which now receives the notifier as a parameter (a constructor injection would recreate the cycle, since EventNotifierService needs StateService for power-level diffs). Both @Inject(delay(() => require(...))) hacks are gone; EventService now injects StateService plainly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…path (#385) Encapsulates the handlePdu -> notify sequencing that StagingAreaService previously hand-rolled across two services. EventService.notify() had no remaining callers and is removed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…tService (#385) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
WalkthroughIntroduces ChangesFederation event pipeline
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #406 +/- ##
==========================================
+ Coverage 51.78% 51.81% +0.03%
==========================================
Files 113 114 +1
Lines 12689 12704 +15
==========================================
+ Hits 6571 6583 +12
- Misses 6118 6121 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/federation-sdk/src/services/event-notifier.service.ts`:
- Around line 158-202: Update the power-level notification logic around
setOrUnsetPowerLevels to also identify users present in oldPowerLevels but
absent from changedUserPowers. Add those removed user IDs to the notified set
and emit homeserver.matrix.room.role for each with role user, ensuring the
existing changed-user loop does not emit duplicates.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4e84ddc1-ec98-4a2e-b5e6-63d84570075d
📒 Files selected for processing (7)
packages/federation-sdk/src/services/event-notifier.service.tspackages/federation-sdk/src/services/event.service.tspackages/federation-sdk/src/services/invite.service.spec.tspackages/federation-sdk/src/services/room.service.tspackages/federation-sdk/src/services/staging-area.service.tspackages/federation-sdk/src/services/state.service.spec.tspackages/federation-sdk/src/services/state.service.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
- GitHub Check: cubic · AI code reviewer
- GitHub Check: Code Quality Checks(lint, test, tsc)
🔇 Additional comments (8)
packages/federation-sdk/src/services/event-notifier.service.ts (1)
23-104: LGTM!packages/federation-sdk/src/services/event.service.ts (1)
55-66: LGTM!Also applies to: 817-822
packages/federation-sdk/src/services/staging-area.service.ts (1)
104-107: LGTM!packages/federation-sdk/src/services/state.service.ts (2)
353-355: LGTM!Also applies to: 463-463
76-82: 🩺 Stability & AvailabilityNo
this.eventServicereferences remain inStateService.packages/federation-sdk/src/services/room.service.ts (1)
35-35: LGTM!Also applies to: 67-67, 812-812
packages/federation-sdk/src/services/invite.service.spec.ts (1)
67-71: LGTM!Also applies to: 210-212, 238-238, 291-291, 379-387
packages/federation-sdk/src/services/state.service.spec.ts (1)
132-136: LGTM!Also applies to: 2126-2126, 2144-2144, 2156-2156
There was a problem hiding this comment.
2 issues found across 7 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/federation-sdk/src/services/event-notifier.service.ts">
<violation number="1" location="packages/federation-sdk/src/services/event-notifier.service.ts:138">
P2: A power-level event without `users` but with `users_default: 50` reports every previously explicit user as `user` instead of `moderator`. Derive the emitted role from the new event's `users_default` value.</violation>
<violation number="2" location="packages/federation-sdk/src/services/event-notifier.service.ts:162">
P1: Removing a user from `content.users` emits no `homeserver.matrix.room.role` update, leaving downstream clients with that user's former role. Include old-only keys in the diff and emit their new effective default role.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Closes #385
Summary by CodeRabbit
New Features
Improvements